﻿using System;
using System.Collections.Generic;
using System.Text;
using JWFW.SFL;
using JWFW.Encrypt;

namespace BaseServer
{
    public class RegCreator
    {
        /// <summary>
        /// 获取注册码
        /// </summary>
        /// <param name="serialNumber"></param>
        /// <param name="toolCode"></param>
        /// <param name="userID"></param>
        /// <param name="endDate"></param>
        /// <param name="extensionInfo"></param>
        /// <returns></returns>
        public static string GetRegCode(string serialNumber, string toolCode, int userID, DateTime endDate, string extensionInfo)
        {
            //Note:{【(软件序列号)+|+@F【工具代号】+|+@F【用户ID】+|+@F【最终日期Date】+|+@F【扩展信息】】} 
            string res = MD5.GetMD5_8(serialNumber) +
                CommonOP.Spliter + Base64.Encrypt(EncryptOP.RandomReverse(EncryptOP.InsertRandom(toolCode))) +
                CommonOP.Spliter + Base64.Encrypt(EncryptOP.RandomReverse(EncryptOP.InsertRandom(userID.ToString()))) +
                CommonOP.Spliter + Base64.Encrypt(EncryptOP.RandomReverse(EncryptOP.InsertRandom(endDate.ToString("yyyy-MM-dd")))) +
                CommonOP.Spliter + Base64.Encrypt(EncryptOP.RandomReverse(EncryptOP.InsertRandom(extensionInfo)));
            return EncryptOP.RandomMultiTimesEncrypt(EncryptOP.InsertRandom(res));
        }


        private RegCreator() { }
        private void Test()
        {
            string a = GetRegCode("12345678", "EmailSpider", 10, DateTime.Now, "GetHttp", "");
            Console.WriteLine("83aa400aĬenJyZTNkbXA0U2xpMGFtRXIvĬdWwxMGsvĬTWcxNDAzSDIwMUcyRAvvĬWHdwdHRrSHRlR2cvĬaFAv");
            Console.WriteLine(a);

        }
    }
}
